// src/utils/tabBus.ts
type EventMap = { refreshCompanyList: void }
const all: Record<string, Array<() => void>> = {}
export default {
  on(key: string, fn: () => void) {
    (all[key] ||= []).push(fn);
  },
  emit(key: string) {
    all[key]?.forEach((fn) => fn());
  },
  off(key: string, fn: () => void) {
    if (!all[key]) return;
    const idx = all[key].indexOf(fn);
    idx > -1 && all[key].splice(idx, 1);
  }
};
